package ui;

import com.jme3.app.state.AbstractAppState;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.elements.render.TextRenderer;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
import game.DataStore;

public class JournalScreenController extends AbstractAppState implements ScreenController {
    protected Nifty nifty;
    protected Screen screen;
    protected Element journalTextArea;

    public void bind(Nifty nifty, Screen screen) {
        this.nifty = nifty;
        this.screen = screen;
        journalTextArea = screen.findElementByName("journalText");
    }

    public void onStartScreen() {
        setEnabled(true);
        updateJournalText();
    }

    public void onEndScreen() {
        setEnabled(false);
    }
    
    public void updateJournalText() {
        journalTextArea.getRenderer(TextRenderer.class).setText(DataStore.player.getJournal().toString());
    }

    @Override
    public void update(float tpf) { 
        /** jME update loop! */
    }
}
